const { DataTypes } = require("sequelize")
const sequelize = require("../config/database")

const Marker = sequelize.define(
  "markers",
  {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    description: {
      type: DataTypes.TEXT,
      allowNull: true,
    },
    position: {
      type: DataTypes.JSON,
      allowNull: false,
    },
    type: {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: "default",
    },
    color: {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: "#ff4d4f",
    },
    building_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      references: {
        model: "building",
        key: "id",
      },
    },
  },
  {
    timestamps: true,
    createdAt: "created_at",
    updatedAt: "updated_at",
    tableName: "markers",
  }
)

module.exports = Marker
